package com.seu.spring.simple.aop;

import java.lang.reflect.Method;

/**
 * @author liangfeihu
 * @since 2018/12/27
 */
public class AfterAdvice implements Advice {
    private Object bean;
    private MethodInvocation methodInvocation;

    public AfterAdvice(Object bean, MethodInvocation invocation) {
        this.bean = bean;
        this.methodInvocation = invocation;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        // 1.执行具体的业务逻辑
        Object result = method.invoke(bean, args);
        // 2.执行切面通知
        methodInvocation.invoke();
        return result;
    }
}
